package com.taojiazheng.controller.file;

import com.taojiazheng.common.ResultResponse;
import com.taojiazheng.common.UpLoadFile;
import com.taojiazheng.dao.job.JobDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 赵成林
 * @date 2017/12/29 12:18
 * 用来发布岗位时的文件上传
 */
@Controller
public class FileController {
    @Autowired
    private JobDao jobDao;
    @Autowired
    private UpLoadFile upLoadFile;
    @ResponseBody
    @RequestMapping("/job/file")
    public ResultResponse jobFile(HttpServletRequest request, MultipartFile file,Integer jobId){
        String url = upLoadFile.uploadFile(file,request);
        String allUrl = "127.0.0.1:8080"+url;
        Map<String,Object> map = new HashMap<String, Object>(); 
        map.put("imageUrl",allUrl);
        map.put("jobId",jobId);
        jobDao.updateUrl(map);
        jobDao.updateJobInfoUrl(map);
        return new ResultResponse();
    }
}
